#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    
    int maxScore=0,maxPos=0;
    string maxName;
    for (int i = 0; i < n; i++)
    {
        int score;
        string name;
        cin >> score >> name;

        if (maxScore == 0)
        {
            maxScore = score;
            maxName = name;
        }
        
        if (score > maxScore)
        {
            maxScore = score;
            maxPos = i;
            maxName = name;
        }
    }
    cout << maxName;   
    
    return 0;
}